<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-grid.min.css">
    <link rel="stylesheet" href="css/bootstrap-reboot.min.css">
    <style>
        img {
            height: auto;
            width: 100%;
        }
    </style>
    <title>blog</title>
</head>
<body>
<div class="container">
    <div class="row" style="margin-top: 20px;">
        <div class="col-12">
            <h2>
                Springboot + ES - 演示博客
            </h2>
        </div>
    </div>

    <div class="row" style="margin-top: 20px;" id="app">
        <div class="col-9">

            <h4 id="title">{{title}}</h4>
            <span>作者：{{author}} | 发布时间：{{createTime}}</span>

            <div v-html="content" style="width: 100%;height: auto;">

            </div>
        </div>
        <div class="col-3">
            <ul class="nav flex-column">
                <li class="nav-item">
                    <a class="nav-link active" href="#">Springboot</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">ES</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">杂谈</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">笔记</a>
                </li>
            </ul>
        </div>
    </div>
</div>
<script src="./js/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/marked.js"></script>
<script>

    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }

    var app = new Vue({
        el: '#app',
        data: {
            title: '',
            author: '',
            createTime: '',
            content: ''
        },
        methods: {
            blog: function () {
                console.log("blog");
                var that = this;
                var id = getQueryVariable("id");
                axios.get('http://localhost:8081/blog/'+id, {}).then(function (response) {
                    that.title = response.data.title;
                    that.author = response.data.author;
                    that.createTime = response.data.createTime;
                    that.content = marked(response.data.content);
                })
            }
        },
        created: function () {
            this.blog();
        }
    })
</script>
</body>
</html>